﻿using System.Collections.Specialized;
using System.Configuration;

namespace ZXW.DotNet.Common.DbUtilities
{
    /// <summary>
    /// DbProvider 与具体 DbHelper 类型的注册表类型
    /// </summary>
    public class DbProviderRegistry
    {
        private const string GroupName =
            "marvellousWorks.practicalPattern.shwoCase";

        private const string SectionName = "dbProviderMappings";
        private static NameValueCollection _collection;

        static DbProviderRegistry()
        {
            _collection = (NameValueCollection)
                          ConfigurationManager.GetSection(string.Format("{0}/{1}", GroupName, SectionName));
        }

        /// <summary>
        /// 获取指定 providerName 对应的 DbHelper 类型
        /// </summary>
        /// <param name="providerName"></param>
        /// <returns></returns>
        public string GetDateBaseType(string providerName)
        {
            return _collection[providerName];
        }
    }
}